package com.sjb.mianshiya.model.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author:sjb
 * @CreateTime:2024-09-24
 * @Description: 题目审核枚举
 * @Version：1.0
 */
@Getter
public enum ReviewStatusEnum {

    REVIEWING("待审核",0),
    PASS("通过",1),
    REJECT("拒绝",2);

    private final String text;
    private final int code;

    ReviewStatusEnum(String text,int code){
        this.text = text;
        this.code = code;
    }

    /**
     * 根据code获取枚举值
     * @param code
     * @return
     */
    public static ReviewStatusEnum getEnumByCode(int code){
        if (ObjectUtil.isEmpty(code)){
            return null;
        }
        for (ReviewStatusEnum statusEnum : ReviewStatusEnum.values()) {
            if (statusEnum.getCode() == code){
                return statusEnum;
            }
        }
        return null;
    }

    /**
     * 获取值列表
     * @return
     */
    public static List<Integer> getListCode(){
        return Arrays.stream(values()).map(item -> item.code).collect(Collectors.toList());
    }
}
